#!C:\Python26
# -*- coding: UTF-8 -*-

import queVars
import time

import urllib2


def printFuncDef(inStr, color=(255, 255, 255)):
	print inStr,

queVars.printFunc = printFuncDef


import plugins.pixivScrape as scrape

import webFunctions

queVars.printToStdout = True


import logmanager

logmanager.initLogging()

scr = scrape.getPx()




if scr.retrievalHandles > 1:
	print "Retrieval Handles - ", scr.retrievalHandles
	handles = []
	for x in range(scr.retrievalHandles):
		handles.append(webFunctions.WebGetRobust())

elif scr.retrievalHandles == 1:

	handles = webFunctions.WebGetRobust()


config = queVars.ConfigValues()
config.ovwMode = "Check Files with Memory"
config.nSrcMode = "Name List File"

config.aList = ["3074092"]


scr.DLFolder 	= r"D:\NekoProfile\Desktop\test"




queVars.configuration = queVars.ConfigValues()


def getMain(config):

	print scr.main(config, handles)

	print "Main done"


def getPage(config):

	scr.log = logmanager.ThreadLog(scr.retrievalHandles)
	scr.log.info("Starting")
	scr.config = config
	scr.getHandles = handles


	name = config.aList[0]
	link = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=31672156"
	#print scr.getpic(link, name, handles)
	print scr.getpic(link, name, handles[0])


def getArtistsList(config):

	scr.log = logmanager.ThreadLog(scr.retrievalHandles)
	scr.log.info("Starting")
	scr.config = config
	scr.getHandles = handles
	print scr.getAllArtistNames(config)


def getCookie():
	handle = webFunctions.WebGetRobust()
	print dir(handle.cj)
	print scr.checkCookie(handle.cj)

	opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(handle.cj))
	username = ""
	password = ""
	print scr.getCookie(username, password, opener)



getArtistsList(config)

print "Thread count: ",
import threading
print threading.activeCount()
print "Threads"
print threading.enumerate()
print "calling sys.exit()"
import sys
sys.exit()
print "exited?"



